The utility functions described in this section implement the QuickTime Media Layer (QTML) and perform miscellaneous tasks to make Windows programs compatible with QuickTime.
InitializeQTML initializes the QuickTime Media Layer.
OSErr InitializeQTML(long flags);
Use InitializeQTML to initialize a QTML session, before calling EnterMovies . You should not make this call from a QuickTime component such as an image decompressor; it is provided only for host applications.
If you are writing a routine that does not know from context whether InitializeQTML has already been called, add a call to InitializeQTML at the beginning of the routine and a call to TerminateQTML at the end. It does no harm to call InitializeQTML more than once, as long as each call is nested with a matching call to TerminateQTML. If InitializeQTML has already been called, subsequent calls do nothing except increment a counter. Calls to TerminateQTML just decrement the counter (if it is nonzero). Only the first nested call to InitializeQTML and the last nested call to TerminateQTML do any actual work, so there is no penalty for having nested calls.
QTMLCreateMutex creates a synchronization object to facilitate mutually exclusive access to a Windows data structure.
QTMLMutex QTMLCreateMutex(void);
The QTMLCreateMutex function creates a mutex object for guarded access to data structures and routines that require mutually exclusive access. In a multithreaded preemptive environment, such as Windows NT, you can use the various mutex utility functions such as QTMLGrabMutex to protect a shared resource from simultaneous access by multiple threads or processes. Mutex objects are used throughout QTML to provide such protection.
QTMLDestroyMutex deallocates a synchronization object created by the QTMLCreateMutex function.
void QTMLDestroyMutex(QTMLMutex theMutex);
QTMLGrabMutex confers ownership of a mutex created by the QTMLCreateMutex function.
void QTMLGrabMutex(QTMLMutex theMutex);
Call the QTMLGrabMutex function when you require exclusive ownership of the resource guarded by the mutex. This function will return when you have gained this ownership. In the case where another thread or process holds the mutex, this function waits until that process or thread relinquishes control. If you need to determine if you can grab the mutex, without actually grabbing it, call QTMLTryGrabMutex .
QTMLTryGrabMutex determines if you would be able to get immediate ownership of a mutex created by QTMLCreateMutex .
Boolean QTMLTryGrabMutex (QTMLMutex theMutex);
QTMLReturnMutex releases ownership of a QTMLMutex object.
void QTMLReturnMutex (QTMLMutex theMutex);
QTMLCreateSyncVar creates a synchronization variable, used to provide guarded access to resources shared across threads and processes.
QTMLSyncVarPtr QTMLCreateSyncVar(void);
Call the QTMLCreateSyncVar function to create a synchronization variable that allows for mutually-exclusive access to resources. The synchronization variable routines use atomic tests to ensure that the portions of the routines that perform the testing cannot be interrupted during the test.
QTMLDestroySyncVar releases ownership of a synchronization variable.
void QTMLDestroySyncVar(QTMLSyncVarPtr p);
QTMLTestAndSetSyncVar performs a one-shot atomic test and set operation of a QTMLSyncVar object.
long QTMLTestAndSetSyncVar(QTMLSyncVarPtr p);
QTMLWaitAndSetSyncVar acquires the lock for a QTMLSyncVar object,
void QTMLWaitAndSetSyncVar(QTMLSyncVarPtr p);
QTMLResetSyncVar reset the lock for a QTMLSyncVar object.
void QTMLResetSyncVar(QTMLSyncVarPtr p);
QTMLRegisterInterruptSafeThread registers a thread of execution that is allowed to make interrupt-safe calls.
void QTMLRegisterInterruptSafeThread(unsigned long threadID, void *info);
The QTML function dispatcher includes a mechanism that prevents not only the Toolbox from getting reentered but also allows certain APIs to be callable at interrupt time. On the Macintosh, these calls are listed in Inside Macintosh, and require that the calling code not allocate, move, or purge memory. On Windows, threads that emulate interrupt handlers need to register with QTML, by calling the QTMLRegisterInterruptSafeThread function, so that API calls made from this thread are not blocked. You should make this call at the top of your thread main routine.
QTMLUnregisterInterruptSafeThread unregisters a thread of execution.
void QTMLUnregisterInterruptSafeThread(unsigned long threadID);
QTMLYieldCPU yields time to other threads while your code is in a tight loop.
void QTMLYieldCPU(void);
QTMLYieldCPUTime yields time to other threads and specifies the sleep time while in a tight loop.
void QTMLYieldCPUTime(long milliSecsToSleep, unsigned long flags);
The QTMLSetWindowWndProc routine allows you to specify an application-defined window procedure ( WNDPROC ) which is called by QTML after QTML processes the message for the HWND .
void QTMLSetWindowWndProc(WindowPtr wPtr, void *windowProc);
The QTMLGetWindowWndProc routine returns the WNDPROC previously specified in QTMLSetWindowWndProc . It returns NULL if no application-defined WNDPROC is set.
void *QTMLGetWindowWndProc(WindowPtr);
| Previous | Chapter Contents | Chapter Top | Roadmap | Next |